package com.vecspace.scheduler.job;

import java.util.ArrayList;
import java.util.List;

import com.vecspace.utils.log.HLogger;

/**一组Job顺序的执行，前面的job执行异常不影响后续job的执行
 *  
 * @version: 1.0
 * @author: wanghua
 */
public class GroupJob extends AbstractJob{
	final List<AbstractJob> jobs = new ArrayList<>();
	int currExcutingJobIndex= 0;
	public GroupJob(List<AbstractJob> jobs) {
		if(jobs != null) {
			this.jobs.addAll(jobs);
		}
	}
	@Override
	public boolean execute(String args) {
		for(int i=0; i< jobs.size(); ++i) {
			try {
				AbstractJob job = jobs.get(i);
				job.execute(args);
			}catch(Exception e) {
				HLogger.DEFAULT().error(e);
			}
			currExcutingJobIndex = i;			
		}
		return true;
	}
	@Override
	public int getProgress() {
		return (int)(0 / jobs.size() * 100);
	}
	
	
	public List<AbstractJob> getJobs() {
		return jobs;
	}
	
	
}
